package com.now.printer.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.now.printer.R;
import com.now.printer.adapter.HelpGridAdapter;
import com.now.printer.base.BaseActivity2;
import com.now.printer.bean.HelpBean;
import com.now.printer.utils.ResUtils;

import org.xutils.common.util.LogUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xudong on 2021/7/3.
 */

public class HelpActivity extends BaseActivity2 {
    private ImageView ivBack;
    private LinearLayout llTitle01;
    private TextView tvTitle01;
    private LinearLayout llTitle02;
    private TextView tvTitle02;
    private GridView gridView;
    private HelpGridAdapter adapter;
    private List<HelpBean> beanList = new ArrayList<>();


    @Override
    public int getLayoutId() {
        return R.layout.activity_help;
    }

    @Override
    public void doBusiness(Context mContext) {
        ivBack = (ImageView) findViewById(R.id.iv_back);
        llTitle01 = (LinearLayout) findViewById(R.id.ll_title01);
        tvTitle01 = (TextView) findViewById(R.id.tv_title01);
        llTitle02 = (LinearLayout) findViewById(R.id.ll_title02);
        tvTitle02 = (TextView) findViewById(R.id.tv_title02);
        gridView = (GridView) findViewById(R.id.gridView);
        adapter = new HelpGridAdapter(this, beanList);
        gridView.setAdapter(adapter);
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        llTitle01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                llTitle01.setBackgroundResource(R.drawable.bg_help_top_select);
                llTitle02.setBackgroundResource(R.drawable.bg_help_top_unselect);
                initData();
            }
        });

        llTitle02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                llTitle01.setBackgroundResource(R.drawable.bg_help_top_unselect);
                llTitle02.setBackgroundResource(R.drawable.bg_help_top_select);
                initData2();
            }
        });
        initData();
    }

    private Drawable[] mMenuIcons;

    private void initData() {
        List<HelpBean> beanList01 = new ArrayList<>();
        Resources res = getResources();
        String[] help_name01 = res.getStringArray(R.array.help_name01);

        for (int i = 0; i < help_name01.length; i++) {
            HelpBean helpBean = new HelpBean();
            helpBean.setName(help_name01[i]);
            helpBean.setContent("点击查看使用说明");
//            helpBean.setmMenuIcons(mMenuIcons[i]);
//            LogUtil.i("图片是:" + mMenuIcons[i]);
            beanList01.add(helpBean);
        }
        adapter.setData(beanList01);
        adapter.setType(1);
    }

    private void initData2() {
        List<HelpBean> beanList01 = new ArrayList<>();
        Resources res = getResources();
        String[] help_name02 = res.getStringArray(R.array.help_name02);
        for (int i = 0; i < help_name02.length; i++) {
            HelpBean helpBean = new HelpBean();
            helpBean.setName(help_name02[i]);
            helpBean.setContent("点击查看");
            beanList01.add(helpBean);
        }
        adapter.setData(beanList01);
        adapter.setType(2);

    }


}

